<template>
  <div class="carComparison">
    <VuePerfectScrollbar class="carComparison-scroll" :settings="settings">
      <div
        class="carComparison-train"
        v-for="(item, index) in trainRateData"
        :key="index"
      >
        <div class="carComparison-train-front">
          <span class="carComparison-train-top">
            {{ `Top${index + 1}` }}
          </span>
          <span class="carComparison-train-info">
            {{ item.info }}
          </span>
        </div>
        <div class="carComparison-train-num">
          {{ item.value }}{{ item.unit }}
        </div>
      </div>
    </VuePerfectScrollbar>
  </div>
</template>

<script>

import VuePerfectScrollbar from "vue-perfect-scrollbar";
export default {
  name:'CarList',
  props:{
    trainRateData: {
      type: Array
    },
  },
  watch: {
    trainRateData: {
      handler(val, old) {
        // console.log(val,'2222222222222222222')
      },
      immediate: true,
      deep:true
    }
  },
  data () {
    return {
      settings: {
        // perfectscrollbar settings
        maxScrollbarLength: 30,
        wheelSpeed: 1,
        swipeEasing: true,
      },
    };
  },
  mounted () {

  },
  methods: {


  },
  components: {
    VuePerfectScrollbar
  },
};
</script>

<style lang="scss" scoped>
.carComparison {
  width: 100%;
  height: 100%;
  &-scroll {
    width: 100%;
    height: 100%;
    padding: 12px 0 20px 0;
  }
  &-train {
    width: 100%;
    height: 40px;
    line-height: 40px;
    font-size: 12px;
    overflow: hidden;
    &-front {
      float: left;
      width: calc(100% - 70px);
      padding-right: 30px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    &-top {
      width: 48px;
      height: 22px;
      text-align: center;
      background: #cde0f9;
      box-sizing: border-box;
      padding: 3px 6px;
      color: #0961db;
      margin-right: 10%;
    }
    &-num {
      float: right;
      color: #0961db;
      width: 40px;
      font-size: 12px;
    }
    &:nth-child(5n + 1) {
      .carComparison-train-top {
        background: rgba(9, 97, 219, 0.2);
        color: rgba(9, 97, 219, 1);
      }
      .carComparison-train-num {
        color: rgba(9, 97, 219, 1);
      }
    }
    &:nth-child(5n + 2) {
      .carComparison-train-top {
        background: rgba(18, 150, 218, 0.2);
        color: rgba(18, 150, 218, 1);
      }
      .carComparison-train-num {
        color: rgba(18, 150, 218, 1);
      }
    }
    &:nth-child(5n + 3) {
      .carComparison-train-top {
        background: rgba(102, 212, 231, 0.2);
        color: rgba(102, 212, 231, 1);
      }
      .carComparison-train-num {
        color: rgba(102, 212, 231, 1);
      }
    }
    &:nth-child(5n + 4) {
      .carComparison-train-top {
        background: rgba(107, 233, 198, 0.2);
        color: rgba(107, 233, 198, 1);
      }
      .carComparison-train-num {
        color: rgba(107, 233, 198, 1);
      }
    }
    &:nth-child(5n + 5) {
      .carComparison-train-top {
        background: rgba(107, 233, 198, 0.2);
        color: rgba(84, 220, 123, 1);
      }
      .carComparison-train-num {
        color: rgba(84, 220, 123, 1);
      }
    }
  }
  .carComparison-train-num{
    width: 65px;
  }
  .carComparison-scroll{
    padding:0;
    padding-left: 20px;
    padding-top: 10px;
  }
}
</style>
